package com.colin.aiyi.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.colin.aiyi.R;
import com.colin.aiyi.dao.ImpxUtils.ImpDoFeedBack;
import com.colin.aiyi.entity.response.BaseResponse;
import com.colin.aiyi.presenter.Interface.Callback;
import com.colin.aiyi.view.ShowMsgUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by hl on 2017/5/31.
 */

public class FeedbackAc extends BaseActivity implements Callback<Object> {
    @BindView(R.id.text_banner_left)
    TextView textBannerLeft;
    @BindView(R.id.text_banner_title)
    TextView textBannerTitle;
    @BindView(R.id.text_banner_rigth)
    TextView textBannerRigth;
    @BindView(R.id.edit_passwd_old)
    TextView editPasswdOld;
    @BindView(R.id.edit_reply)
    EditText editReply;
    @BindView(R.id.button_send)
    Button buttonSend;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ac_feelback);
        ButterKnife.bind(this);
        textBannerTitle.setText("反馈");
        textBannerLeft.setOnClickListener(this);
        user=getUser();
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.button_send:
                String cont=editReply.getText().toString().replace(" ","");
                if (cont==null||cont.length()<1){
                    showMsg("请输入反馈内容");
                    return;
                }
            //    ImpOther.getInstance().doFeedBack(cont);
                user.setTitle(cont);
                new ImpDoFeedBack().getObject(this,user);
                ShowMsgUtil.showLoadingDialog(this);
                finish();
                break;
        }
    }

    @Override
    public <T extends BaseResponse> void checkResponseBase(T t) {
        super.checkResponseBase(t);
    }

    @Override
    public void onSuccess(Object t) {
        ShowMsgUtil.hideLoadingDialog();
        if ( t instanceof BaseResponse){
           if(((BaseResponse) t).getCode()==200){
                showMsg("反馈成功");
            }else {
               showMsg(((BaseResponse) t).getMessage());
           }
        }
    }

    @Override
    public void onFailed(Exception e) {
            showMsg("反馈失败");
    }
}
